<?php
namespace app\superAdmin\controller;
use \think\Controller;
use \think\Db;


class Advertise extends Controller 
{
	public function index()
    {
    	$advertises = Db::name('advertise_ck')->select();
    	$this->assign("advertiseList",$advertises);
        return $this->fetch();;
    }
    public function jujue($id){
       
        $ustatenum=Db::name("advertise_ck")->where("adid='$id'")->value('adstate');

        if($ustatenum！=2){
            if (Db::name("advertise_ck")->where("adid='$id'")->update(['adstate'=>2])) {
                $this->success('拒绝成功');
            }else{
                $this->error('拒绝失败');
            }

        }

	
	}
    public function tongguo($id){
        $ustatenum=Db::name("advertise_ck")->where("adid='$id'")->value('adstate');
        if($ustatenum！=1){
            if (Db::name("advertise_ck")->where("adid='$id'")->update(['adstate'=>1])) {
                $this->success('审核通过成功');
            }else{
                $this->error('审核通过失败');
            }

        }
    }
    public function find(){
        $findid=input('findid');
        $findstate=input('findstate');
        $findname=input('findname');

        if ($findid!=NULL) {
            $registration=Db::query("select * from `advertise_ck` where adid='$findid'");
            $this->assign("advertiseList",$registration);
            return $this->fetch("index");
        }elseif ($findstate!=NULL) {
            $registration=Db::query("select * from `advertise_ck` where adstate='$findstate'");
            $this->assign("advertiseList",$registration);
            return $this->fetch("index");
        }elseif ($findname!=NULL) {
            $registration=Db::query("select * from `advertise_ck` where adname='$findname'");
            $this->assign("advertiseList",$registration);
            return $this->fetch("index");
        }else{
            $registration=Db::query("select * from `advertise_ck`");
            $this->assign("advertiseList",$registration);
            return $this->fetch("index");
        }
    }

}